<template>
    <div>
        <!--            标题-->
        <el-row class="border_bottom" type="flex" justify="start">
            <el-col :span="1">
                <h3> 签到管理</h3>
            </el-col>
        </el-row>

        <div style="'width:500px'">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm">
                <el-form-item label="签到积分" prop="signManageFirst">
                    <el-input v-model="ruleForm.signManageFirst"></el-input>
                </el-form-item>
                <el-form-item label="是否递增模式" prop="moshi">
                    <el-radio-group v-model="ruleForm.moshi">
                        <el-radio label="是"></el-radio>
                        <el-radio label="否"></el-radio>
                    </el-radio-group>
                    <p>要片启递增模式，则需要同时设置每大递增积分、赠送积分的最大值。
                        递增模式下，连续签到所获得积分为:签到积分+已签到天数*每天递增积分。
                        例:签到积分:5，每天递增积分:1，那么第一天签到就是:5+0*1=5，第二天就是5+1*1=6，以此类推。当达到赠送积分最大值后，则不管再连续签到几天，都只赠送积分最大值对应的积分。
                    </p>
                </el-form-item>
                <el-form-item label="每天递增积分" prop="signManageAdd">
                    <el-input v-model="ruleForm.signManageAdd"></el-input>
                </el-form-item>
                <el-form-item label="赠送积分最大值" prop="signManageMax">
                    <el-input v-model="ruleForm.signManageMax"></el-input>
                </el-form-item>
                <el-form-item label="是否保留签到日志" prop="rizhi">
                    <el-radio-group v-model="ruleForm.rizhi">
                        <el-radio label="是"></el-radio>
                        <el-radio label="否"></el-radio>
                    </el-radio-group>

                </el-form-item>
                <el-form-item label="签到日志保存天数" prop="rizhiday">
                    <el-input v-model="ruleForm.rizhiday"></el-input>
                    <span>为每个用户保存签到日志多少天，0表示不限制。
</span>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>

                </el-form-item>
            </el-form>

        </div>
    </div>

</template>

<script>
    import qs from 'qs'
    import axios from 'axios'

    export default {
        name: "SignInManagement",
        data() {
            return {
                radio: '1',
                ruleForm: {
                    signManageFirst: '',
                    rizhiday: '',
                    rizhi: '',
                    signManageAdd: '',
                    moshi: '',
                    signManageMax: ''
                },
                rules: {
                    name: [
                        {required: true, message: '请输入活动名称', trigger: 'blur'},
                        {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
                    ],
                    region: [
                        {required: true, message: '请选择活动区域', trigger: 'change'}
                    ],
                    date1: [
                        {type: 'date', required: true, message: '请选择日期', trigger: 'change'}
                    ],
                    date2: [
                        {type: 'date', required: true, message: '请选择时间', trigger: 'change'}
                    ],
                    type: [
                        {type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change'}
                    ],
                    resource: [
                        {required: true, message: '请选择活动资源', trigger: 'change'}
                    ],
                    desc: [
                        {required: true, message: '请填写活动形式', trigger: 'blur'}
                    ]
                }
            }
        },
        methods: {
            open4() {
                ;
            }
            ,
            submitForm() {
                this.$axios.post('/api/sign/signManage?signManageFirst='+ this.ruleForm.signManageFirst+'&signManageAdd='+this.ruleForm.signManageAdd+'&signManageMax='+this.ruleForm.signManageMax,

                ).then((res) => {
                    console.log(res);
                    if (res.data.code == 200) {

                        this.$message({
                            type: 'success',
                            message: '修改成功!'
                        });

                    }else{
                        this.$message.error('出错了哦，请确保信息填写完整')
                    }

                })

            }


        },
        //加载以前日志
        // created() {
        //     this.$axios.post('/api/getSignInManagement').then((res)=>{
        //         var obj = res.data[0]
        //         console.log(obj)
        //         this.ruleForm.jifen=obj.jifen
        //         this.ruleForm.rizhiday=obj.rizhiday
        //         this.ruleForm.zengjifen=obj.zengjifen
        //         this.ruleForm.rizhi=obj.rizhi
        //         this.ruleForm.moshi=obj.moshi
        //         this.ruleForm.maxjifen=obj.maxjifen
        //     })
        //
        //
        //
        // }
    }
</script>

<style scoped>
    .border_bottom {

        border-bottom: 1px solid grey;
    }

    .border {

        border: 1px solid red;
    }

    .padd {

        text-align: left;
    }

    .el-col {
        text-align: left;
    }

    .demo-ruleForm {
        width: 800px;

    }

    .el-input {
        width: 300px;
    }

    .el-form-item {
        text-align: left;
    }
</style>